class View {
    drawOn() {

    }
}
class Point {
    declare x: number
    declare y: number
    constructor(x: number, y: number) {
        this.x = x
        this.y = y
    }
}
export abstract class Window {
    declare _imp: WindowImp
    declare _content: View
    constructor(contents: View) {
        this._content = contents
    }

    //由window请求处理
    abstract drawContents(): void

    abstract open(): void
    abstract close(): void
    abstract iconify(): void
    abstract deiconify(): void

    //请求转发给实现
    abstract setOrigin(at: Point): void
    abstract setExtent(extent: Point): void
    abstract raise(): void
    abstract lower(): void

    abstract drawLine(at: Point, at2: Point): void
    abstract drawRect(at: Point, at2: Point): void
    abstract drawPolygon(ats: Point[], n: number): void
    abstract drawText(str: string, at: Point): void

    abstract getWindowImp(): WindowImp
    abstract getView(): View
}

abstract class WindowImp {
    abstract ImpTop(): void;
    abstract ImpBottom(): void;
    abstract ImpSetExtent(extent: Point): void;
    abstract ImpSetOrigin(at: Point): void;
    abstract DeviceRect(x1: number, y1: number, x2: number, y2: number): void;
    abstract DeviceText(str: string, x: number, y: number): void;
    abstract DeviceBitmap(str: string, x: number, y: number): void;
    // lots more functions for drawing on windows...
}

class ApplicationWindow extends Window {
    drawContents(): void {
        this.getView().drawOn()
    }
    open(): void {
        throw new Error("Method not implemented.")
    }
    close(): void {
        throw new Error("Method not implemented.")
    }
    iconify(): void {
        throw new Error("Method not implemented.")
    }
    deiconify(): void {
        throw new Error("Method not implemented.")
    }
    setOrigin(at: Point): void {
        throw new Error("Method not implemented.")
    }
    setExtent(extent: Point): void {
        throw new Error("Method not implemented.")
    }
    raise(): void {
        throw new Error("Method not implemented.")
    }
    lower(): void {
        throw new Error("Method not implemented.")
    }
    drawLine(at: Point, at2: Point): void {
        throw new Error("Method not implemented.")
    }
    drawRect(at: Point, at2: Point): void {
        throw new Error("Method not implemented.")
    }
    drawPolygon(ats: Point[], n: number): void {
        throw new Error("Method not implemented.")
    }
    drawText(str: string, at: Point): void {
        throw new Error("Method not implemented.")
    }
    getWindowImp(): WindowImp {
        throw new Error("Method not implemented.")
    }
    getView(): View {
        throw new Error("Method not implemented.")
    }

}
class IconWindow extends Window {

    declare bitmapName: string
    drawContents(): void {
        const imp = this.getWindowImp()
        if (imp != null) {
            imp.DeviceBitmap(this.bitmapName, 0.0, 0.0)
        }
    }
    open(): void {
        throw new Error("Method not implemented.")
    }
    close(): void {
        throw new Error("Method not implemented.")
    }
    iconify(): void {
        throw new Error("Method not implemented.")
    }
    deiconify(): void {
        throw new Error("Method not implemented.")
    }
    setOrigin(at: Point): void {
        throw new Error("Method not implemented.")
    }
    setExtent(extent: Point): void {
        throw new Error("Method not implemented.")
    }
    raise(): void {
        throw new Error("Method not implemented.")
    }
    lower(): void {
        throw new Error("Method not implemented.")
    }
    drawLine(at: Point, at2: Point): void {
        throw new Error("Method not implemented.")
    }
    drawRect(at: Point, at2: Point): void {
        throw new Error("Method not implemented.")
    }
    drawPolygon(ats: Point[], n: number): void {
        throw new Error("Method not implemented.")
    }
    drawText(str: string, at: Point): void {
        throw new Error("Method not implemented.")
    }
    getWindowImp(): WindowImp {
        throw new Error("Method not implemented.")
    }
    getView(): View {
        throw new Error("Method not implemented.")
    }

}